<%--
  Created by IntelliJ IDEA.
  User: wqz
  Date: 2020/12/27
  Time: 23:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>商品展示页</title>
</head>
<style type="text/css">
    .divBox{
        width: 85%;
        margin: 0 auto;
    }
    h1,h3{
        text-align: center;
    }
    table{
        width: 100%;
    }
    table tr{
        width: 19%;
        text-align: center;
    }
    .thead{
        background: #8EAFC0;
        color: #fff;
    }
    table tr:nth-child(2n){
        background-color: #fbc9a7
    }
</style>
<body>
<div class="divBox">
    <h1>商品信息表</h1>
    <h3><a href="/index/zhuce">添加商品</a></h3>
    <h3><a href="/index/show">搜索页</a></h3>
    <table id="aa">
        <tr class="thead">
            <td>序号</td>
            <td>商品姓名</td>
            <td>商品类型</td>
            <td>商品价钱</td>
            <td>出版时间</td>
            <td>商品描述</td>
            <td>操作</td>
        </tr>
    </table>
</div>


</body>
<script src="/js/jquery-1.11.1.min.js" type="text/javascript" charset="UTF-8"></script>
<script>
    $(function () {

        $.ajax({
            type: "POST",
            url: "/commodity/findCommodityList",
            dataType: "json",
            async: false,//改为同步
            success: function (data) {
                $.each(data, function (k, v) {
                    $("#aa").append(
                        "<tr><td>" + (k + 1) + "</td>" +
                        "<td>" + v['name'] + "</td>" +
                        "<td>" + v['type'] + "</td>" +
                        "<td>" + v['price'] + "</td>" +
                        "<td>" + v['publish_time'] + "</td>" +
                        "<td>" + v['description'] + "</td>" +
                        "<td><a href='/commodity/deleteCommodity?id="+v['id']+"'>删除</a></td>" +
                        "</tr>")
                });
            }
        });
    })
</script>
</html>
